package com.yangguang.huahui.api;

import com.yangguang.huahui.Config;
import com.yangguang.huahui.entity.BuyEditInfo;
import com.yangguang.huahui.entity.ClientNeeds;
import com.yangguang.huahui.entity.HttpResult;
import com.yangguang.huahui.entity.PublishList;

import java.util.Map;

import okhttp3.ResponseBody;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Administrator on 2017/3/6.
 */

public interface PurchaseApi {
    /**
     * 客户需求
     * @param page
     * @return
     */
    @GET(Config.CLIENT_NEEDS)
    Observable<ClientNeeds> client_needs_list(@Query("page") int page);

    /**
     * 发布采购
     * @param uid
     * @param goods_type 商品类别(二级)
     * @param variety 品种
     * @param goods_title 商品名称
     * @param high_price 高价
     * @param low_price 低价
     * @param demand 需求量
     * @param source_id 货源地id
     * @param receipt_address 收货地址
     * @param deadline 采购截止日期
     * @param contacts 联系人
     * @param phone 联系电话
     * @param remark 补充说明
     * @return
     */
    @FormUrlEncoded
    @POST(Config.PUBLISH_PURCHASE)
    Observable<HttpResult> publish(@Field("uid") String uid, @Field("goods_type") String goods_type, @Field("variety") String variety,
                                   @Field("goods_title") String goods_title, @Field("high_price") String high_price, @Field("low_price") String low_price,
                                   @Field("demand") String demand, @Field("source_of_supply_id") String source_id, @Field("receipt_address") String receipt_address,
                                   @Field("deadline") String deadline, @Field("contacts") String contacts, @Field("phone") String phone, @Field("remark") String remark);

    @GET(Config.PUBLISH_PURCHASE_LIST)
    Observable<PublishList> getPublish(@Query("uid") String uid);

    @FormUrlEncoded
    @POST(Config.PUBLISH_PURCHASE_DELETE)
    Observable<PublishList> delete(@Field("id") String id);

    @GET(Config.PUBLISH_PURCHASE_REFRESH)
    Observable<PublishList> refresh(@Query("id") String id, @Query("uid") String uid);

    @GET(Config.PUBLISH_PURCHASE_EDIT)
    Observable<BuyEditInfo> getInfo(@Query("id") String id);

    @FormUrlEncoded
    @POST(Config.PUBLISH_PURCHASE_EDIT)
    Observable<HttpResult> edit(@FieldMap Map<String, String> map, @Field("sign") String sign);
}
